Skip to content

dgb: M3 §7b scrypt digest -> pow_hash little-endian conversion (u256::from_le_bytes) - #155

Closed
frstrtr wants to merge 2 commits into
dgb/m3-scrypt-window-walkfrom
dgb/m3-scrypt-digest-conv
Closed

dgb: M3 §7b scrypt digest -> pow_hash little-endian conversion (u256::from_le_bytes)#155
frstrtr wants to merge 2 commits into
dgb/m3-scrypt-window-walkfrom
dgb/m3-scrypt-digest-conv

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #153 (held until #153 merges; merge order #151(done) -> #153 -> this).

Scope: src/impl/dgb/ ONLY. Header-only, -only, no btclibs link, no shared-base/bitcoin_family entanglement.

What it does:

  • Adds u256::from_le_bytes: maps a 32-byte little-endian Scrypt digest into u256 (limb[0] = least-significant 8 bytes), byte-identical to DigiByte Core UintToArith256. This fills the FIELD half of pow_hash for the §7b ingest gate.
  • Test: +1 vector folded INTO header_chain_test (no new gtest target -> avoids the ci: build test_dgb_subsidy in both Linux test jobs (fix master-red NOT_BUILT) #143 NOT_BUILT allowlist trap). Covers LE mapping + zero/max boundaries + feeds the full-width PoW-satisfaction gate.

Evidence (head b1e7bc7): header_chain_test 22/22 PASS, build EXIT=0.

NOTE: this lands the conversion primitive only. The actual scrypt() CALL at ingest (which needs scrypt.cpp linkage) is the SEPARATE pending slice flagged to integrator for (a) link scrypt.cpp into header_chain_test vs (b) call in node.cpp + exe-smoke — not in this PR.

HOLD merge — integrator clears in dependency order.

frstrtr added 2 commits June 18, 2026 13:13
…:from_le_bytes)

Add u256::from_le_bytes: builds a 256-bit value from a 32-byte little-endian
digest (the scrypt_1024_1_1_256 PoW output), limb[0] = least-significant 8
bytes, mirroring bitcoin UintToArith256. This is the bytes->field half of
dropping the embedded DigiByte Core Scrypt digest into HeaderSample::pow_hash
at the ingest boundary; the scrypt CALL itself (btclibs) lands next slice.

Header-only, depends only on <cstdint>/builtin unsigned char, so the standalone
header_chain guard keeps linking with NO btclibs scrypt dependency. +1 vector
folded INTO header_chain_test (no new gtest target; #143 NOT_BUILT trap avoided):
pins LE limb mapping, zero/max boundaries, and proves a converted digest feeds
the existing full-width PoW-satisfaction gate (not a low64 proxy). 22/22 PASS.
…024_1_1_256

Links the btclibs Scrypt PoW TU set (scrypt.cpp + SHA256 family) into
header_chain_test and adds an end-to-end test that runs the real
scrypt_1024_1_1_256 over an 80-byte header, converts the 32-byte LE digest
via u256::from_le_bytes, pins it as a self-derived KAT, and feeds it through
the live full-width satisfaction gate (accept vs pow_limit, reject vs a
tiny target -> proves full-width ordering, not a low64 proxy). Compiles only
the scrypt + SHA256 crypto TUs directly (not the full btclibs archive, whose
siphash TU needs the removed base_uint<256> symbol, and not core/the dgb
OBJECT lib) -- linking an existing scrypt.cpp, no shared source modified.
Same target name, still in both build.yml --target allowlists.

Proves the conversion primitive end-to-end against a genuine Scrypt digest;
does NOT wire scrypt into the production node.cpp ingest path (that lands in
embedded-daemon Phase A, scoped with an exe-smoke).
@frstrtr

frstrtr commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #158. Base branch dgb/m3-scrypt-window-walk predates the #153 squash-merge (81fef6a), so this PR diffed the whole already-merged §7b stack. #158 carries the same digest-conversion commits (04f1da6 + 4d62bbc) cherry-picked clean onto current master, plus the integrator-accepted retarget-no-op + MTP-guard tail. Branch preserved (no --delete-branch).

@frstrtr frstrtr closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant